/// @tags:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <tr1/unordered_map>
#include <vector>

using namespace std;

namespace BlueQuantum {

typedef long long LL;
typedef pair<int, int> par;

int const N = 3e5 + 5;

struct Node {
  int u, v, ty;
  Node(int _u = 0, int _v = 0, int _ty = 0) : u(_u), v(_v), ty(_ty) {}
  LL gethash() { return (LL)u * N * 2 + v * 2 + ty; }
};

int n, m, cnt;
int stk[N], pfm[N];
bool del[N], rev[N];
LL ans;
tr1::unordered_map<LL, int> h;
map<par, int> path;
vector<int> vec[N];

inline int val(par pr, int rev) {
  LL tmp = Node(pr.first, pr.second, rev).gethash();
  if (h.find(tmp) == h.end()) return 0x7fffffff;
  else
    return h[tmp];
}

inline int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) cin >> pfm[i];
  int tot;
  cin >> tot;
  char typ;
  for (int i = 1, u, v, w; i <= tot; ++i) {
    cin >> u >> v >> typ >> w, typ = (typ == 'R');
    if (!h.count(Node(u, v, typ).gethash())) h[Node(u, v, typ).gethash()] = w;
    else
      h[Node(u, v, typ).gethash()] = min(h[Node(u, v, typ).gethash()], w);
  }
  for (int i = 1; i < m; ++i) {
    int x = pfm[i], y = pfm[i + 1];
    if (x > y) swap(x, y), rev[i] = true;
    if (path.find(par(x, y)) == path.end()) path[par(x, y)] = ++cnt;
    vec[path[par(x, y)]].push_back(i);
  }
  for (auto mpr : path) {
    if (!vec[mpr.second].size()) continue;
    par pr = mpr.first, ipr = par(pr.second, pr.first);
    LL A = val(pr, 0), B = val(ipr, 0), AB = val(pr, 1), BA = val(ipr, 1);
    bool revv = false;
    A = min(A, AB), B = min(B, BA), AB = min(AB, A + B), BA = min(BA, B + A);
    if (AB > BA) swap(A, B), swap(AB, BA), revv = true;
    memset(del, 0, sizeof(bool) * vec[mpr.second].size());
    for (int i = 0, top = 0; i < int(vec[mpr.second].size()); ++i) {
      if (rev[vec[mpr.second][i]] == revv) stk[++top] = i;
      else if (top)
        del[stk[top--]] = del[i] = 1, ans += AB;
    }
    for (int i = 0, top = 0; i < int(vec[mpr.second].size()); ++i) {
      if (!del[i]) {
        if (rev[vec[mpr.second][i]] != revv) stk[++top] = i;
        else if (top)
          del[stk[top]] = del[i] = 1, top--, ans += BA;
      }
    }
    for (int i = 0; i < int(vec[mpr.second].size()); ++i)
      if (!del[i]) ans += rev[vec[mpr.second][i]] == revv ? A : B;
  }
  cout << ans;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P3686 [CERC2016] 爵士之旅 Jazz Journey.in", "r", stdin);
  freopen("P3686 [CERC2016] 爵士之旅 Jazz Journey.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
